﻿package com.bluediesel.utils.managers.scenemanager.commands.greensock {
	import com.bluediesel.utils.managers.scenemanager.commands.Command;
	import com.greensock.TweenMax;
	
	//this command encapsulates the TweenMax.to() method
	public class TweenMaxTo extends Command {
		
		public var duration:Number;
		public var vars:Object;
		
		public function TweenMaxTo(obj:Object, duration:Number, vars:Object) {
			
			super(obj);
			this.duration = duration;
			this.vars = vars;
		}
		
		override public function executeAll():void {
			
			while (targets.length > 0) {
				vars.onComplete = countDownTargets;
				this.execute(targets.pop());
			}
		}
		
		override protected function execute(obj:Object = null):void
		{
			TweenMax.to(obj, duration, vars);
		}
	}
}